﻿using UnityEngine;
using System.Collections;

public class Aiming : MonoBehaviour {
	
	public GameObject target;
	
	LayerMask layerMask;
	
	// Use this for initialization
	void Start () {
		layerMask = (1 << LayerMask.NameToLayer("Player"));
		layerMask = ~layerMask;
	}
	
	// Update is called once per frame
	void Update () {
		
		
		RaycastHit hit;
		if(Physics.Raycast(transform.position, transform.forward, out hit, 10000, layerMask)){
			target.transform.position = hit.point;
		}
		else{
			target.transform.position = transform.position + transform.forward * 1000;
		}
	}
}
